﻿using Epic.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;

namespace Epic.ComponentServices
{
    public class LocalizationResourceAttribute : Attribute
    {
        public Type ResourceType { get; private set; }
        public string ResourceName { get; private set; }
        public Type UsingResourceSet { get; set; }
        public string Prefix { get; set; }

        public LocalizationResourceAttribute() { }
        public LocalizationResourceAttribute(string resourceName)
        {
            ResourceName = resourceName;
        }
        public LocalizationResourceAttribute(Type resourceType)
            : this(resourceType.AssemblyQualifiedName)
        {
            ResourceType = resourceType;
        }

        public ResourceManager GetResourceManager()
        {
            if (ResourceType != null)
                return ResourceUtility.GetResourceManager(ResourceType, UsingResourceSet);

            if(ResourceName != null)
                return ResourceUtility.GetResourceManager(ResourceName, UsingResourceSet);

            return null;
        }
    }
}
